﻿@{
	Layout = null;
}

<!DOCTYPE html>
<html>
<head>
	<title>上传</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link href="~/lib/dropzone/basic.min.css" rel="stylesheet" asp-append-version="true" />
	<link href="~/lib/dropzone/dropzone.min.css" rel="stylesheet" asp-append-version="true" />
	<link href="~/css/app.css" rel="stylesheet" asp-append-version="true" />
	<link href="//at.alicdn.com/t/font_1956173_tc74it1f66.css" rel="stylesheet" asp-append-version="true" />
	@*<link href="~/lib/bootstrap/bootstrap-3.3.7.min.css" rel="stylesheet" asp-append-version="true" />
		<link href="~/lib/adminlte/css/adminlte-2.4.8.min.css" rel="stylesheet" asp-append-version="true" />
		<link href="~/lib/adminlte/css/skins/skin-blue.min.css" rel="stylesheet" asp-append-version="true" />
	*@
	<style>
		.dropzone .dz-message {
			line-height: 22px;
			margin: 0;
			font: 14px Helvetica Neue,Helvetica,PingFang SC,Tahoma,Arial,sans-serif;
			color: #999;
		}

		.dropzone {
			min-height: 22px;
			padding: 5px 20px;
		}

		.dropzone i {
			font-size: 30px;
			color: #009688;
			display: block;
		}

		.dropzone .dz-preview.dz-file-preview .dz-image {
			background: none;
		}

		.dropzone .dz-preview .dz-details {
			line-height: 100%;
			padding: 0 1em;
		}

		.dropzone .dz-preview .dz-image {
			height: 40px;
		}

		.dropzone .dz-preview .dz-details .dz-size {
			margin-bottom: 5px;
		}

		.dropzone .dz-message:before {
			font-size: 30px;
			color: #009688;
			display: block;
			font-family: iconfont;
			font-weight: normal;
			font-style: normal;
			text-decoration: inherit;
			-webkit-font-smoothing: antialiased;
			content: "\ef78";
		}
	</style>
</head>
<body style="margin:0;padding:0;">
	<div class="dropzone needsclick dz-clickable" id="dropzoneForm" style="margin:5px 7px 5px 0;border: 1px dashed #e2e2e2; text-align: center;">
		<div class="fallback">
			<input name="file" type="file" multiple />
			<input type="submit" value="Upload" />
		</div>

	</div>
	@*<div style="text-align: center; margin-top: 10px;">
			<button class="btn btn-primary" id="btnUpload" onclick="doUpload();return false;" style="margin-right: 80px;">
				<i class="icon-upload"></i>上传
			</button>
			<button class="btn btn-warning" id="btnCancel" onclick="window.close();return false;">
				<i class="icon-remove"></i>取消
			</button>
		</div>*@
	<script src="~/lib/dropzone/dropzone.min.js" asp-append-version="true"></script>
	<script type="text/javascript">
		Dropzone.autoDiscover = false;
		var myDropzone = new Dropzone("#dropzoneForm", {
			maxFiles: 10,
			dictMaxFilesExceeded: '最大上传文件数为1',
			parallelUploads:10,//同时上传最大文件数
			maxFilesize: @ViewBag.MaxFileSizeOfM,//M
			url: "@Url.Action("Upload", "Sys")",
			params:{type:'@(ViewData["type"])',callback:'' },
			addRemoveLinks: true,
			dictRemoveFile: '删除',
			dictCancelUpload: '取消上传',
			dictCancelUploadConfirmation: '文件正在上传中，取消上传可能会造成数据有误，确定取消吗？',
			createImageThumbnails: @ViewBag.ImageThumbnails,
			acceptedFiles: '@ViewBag.Exts',
			autoProcessQueue: true,
			dictDefaultMessage: '点击上传，或将文件拖拽到此处',
			dictInvalidFileType: '不支持此类文件',
			init: function () {
				this.on("maxfilesexceeded", function (file) {
					//var files = this.getQueuedFiles();
					//myDropzone.removeFile(files[0]);
					myDropzone.removeFile(file);
					//myDropzone.addFile(file);
				});
				this.on("success", function (file, ret) {
					if (ret.r) {
						if (window.opener && window.opener.@(ViewData["callback"])) {
							window.opener.@(ViewData["callback"])(ret.data, "@(@ViewBag.Exts)");
						}
						if (window.parent && window.parent.@(ViewData["callback"])) {
							window.parent.@(ViewData["callback"])(ret.data, "@(@ViewBag.Exts)");
						}
					} else {
						window.opener && window.opener.utils && window.opener.utils.alert(ret.m || "上传失败");
						window.parent && window.parent.utils && window.parent.utils.alert(ret.m || "上传失败");
					}
					myDropzone.removeFile(file);
				});
				this.on("complete", function (file) {
				});
				this.on('queuecomplete', function () {
					window.close();
				});

			}
		});
	</script>
</body>
</html>
